<p>	Here you can add the necessary currencies and link email addresses and cell-phone numbers to a wallet. 
	Linking means that a payment made, for example, to a certain email address will be credited to this particular wallet.</p>

<h3 class='sectionTitle'>General</h3>

<div style="border:none;" class="form">
	<?php $walletCode = $wallet["WALLET_CODE"]; ?> 
	<form id="saveWalletForm" method='post' action="<?php echo site_url("user/account/profile/wallet/" . $walletCode . "/save")?>"  onsubmit="return Send('#saveWalletForm');">
		
		<div class="line error-input">
			<label id="Description" for="txtDescription">Title</label>
			<input type="text" class="text" id="txtDescription" name="txtDescription" value="<?php echo $wallet["NAME"];?>" />
			<span id="errorDescription" style='display: inline-block;margin-left: 15px;margin-top: 8px;'></span>
		</div>
		
		<div style='clear:both;'></div>
		<div class="line">
			<label id="walletIDLbl" for="walletID">Wallet ID</label>
			<span id="walletID" class="value"><strong>
				<?php echo $walletCode;?>
			</strong></span>
		</div>
		
		<div style='clear:both;'></div>
		<div class="line">
			<label id="openedDateLbl" for="openedDate">Date Opened</label>
			<span id="openedDate" class="value"><strong>
				<?php echo date("j/m/Y", strtotime($wallet["DATE_OPENED"])); ?> 
			</strong></span>
		</div>
		<div style='clear:both;'></div>
		<div class="input-button-block">
			<input type="submit" id="btnSaveWallet" onclick="" value="Save" name="btnSaveWallet">
		</div>
	</form>
</div>



<h3 class='sectionTitle'>Currencies</h3>
<table id='currentCurrencies' width="100%" cellspacing="0" class="itemList">
	<thead>
	<tr>
		<th width="5%"></th>
		<th width="30%" align="left">Currency</th>
		<th width="45%">Balance</th>
		<th class='rightColumn'></th>
	</tr>	
	</thead>
	
	<tbody>
	<?php $is_multiple_vals = count($wallet['currencies']) > 1 ? true : false; ?>
	<?php foreach ($wallet['currencies'] as $key => $val):?>
	<tr>
		<td></td>
		<td>
			<?php 
				echo $val['C_SYMBOL'];
			?>	
		</td>
		<td>
			<?php 
				$ammount = number_format($val['AMMOUNT'], 2, '.', '');
				echo $val['C_SIGN'] . $ammount .  "&nbsp;" . $val['C_SYMBOL'];
			?>	
		</td>
		<td>
		<?php if($is_multiple_vals):?>
			<input type="button" class="removeCurrency red" value='Remove' onclick='removeCurr("<?php echo $wallet['ID'] . "-" . $val['ID'];?>");' />
		<?php endif;?>
		</td>
		
	</tr>	
	<?php endforeach;?>
	</tbody>
</table>

<?php if(count($av_currencies) > 0):?>
<p>
	<?php echo "<a id='add_currency' href='#'>Add currency</a>";?> 
</p>
<?php endif;?>
<p>
	<?php echo anchor("user/account/profile/wallets", "Return to wallets information");?> 
</p>


<div id="addCurrency" title="Add Currency" style="display:none;" style="height: 230px; min-height: 100px; width: auto;" class="ui-dialog-content ui-widget-content">
	<div style="border:none;" class="form">
		<div id="errorDescription"></div>
		<form id="addCurrencyForm" method='post' action="<?php echo site_url("user/account/profile/wallet/" . $walletCode . "/addCurrency")?>"  onsubmit="return Send('#addCurrencyForm');">
			<div class="line">
				<label id="Currencies" for="ddlCurrencies">Select Currency</label>
				<select id="ddlCurrencies" name="ddlCurrencies">
				<?php foreach ($av_currencies as $key => $val):?>
					<option value="<?php echo $key;?>"><?php echo $val;?></option>
				<?php endforeach;?>
				</select>
			</div>
			<div style='clear:both;'></div>
			<fieldset class="submit">
				<div class="input-button-block">
					<input type="submit" id="btnAddWallet" onclick="" value="Add" name="btnAddWallet">
				</div>
			</fieldset>
		</form>
	</div>
	<div id='loader' style='display:none;'>
		<img src='<?php echo base_url()?>public/images/loading.gif' alt='Loading...' />
	</div>
</div>




<script type="text/javascript">
	function removeCurr(id) {
		$.post(
			'<?php echo site_url("user/account/profile/wallet/" . $wallet['WALLET_CODE'] . "/removeCurr");?>', 
			{currID: id},
			function(data) {
			  if(data.refresh){
				  location.reload(true);
			  }
		},
		"json");
	}
</script>